///*
// * To change this template, choose Tools | Templates
// * and open the template in the editor.
// */
//
//package br.great.functionalCore;
//
//import br.great.beans.PossibleTag;
//import com.restfb.DefaultFacebookClient;
//import com.restfb.FacebookClient;
//import com.restfb.FacebookToken;
//import com.restfb.TokenFile;
//import com.restfb.json.JsonObject;
//import com.restfb.types.Event;
//import java.io.FileNotFoundException;
//import java.io.IOException;
//import java.text.ParseException;
//import java.util.ArrayList;
//import java.util.Date;
//
///**
// *
// * @author Drazzco
// */
//public class FacebookEventInference
//{
//     ArrayList<PossibleTag> vtPossibleTag;
//
//    /** Creates a new instance of FriendInference */
//    public FacebookEventInference()
//    {
//        vtPossibleTag = new ArrayList<PossibleTag>();
//    }
//    public ArrayList<PossibleTag> generateTagsFromFacebook(Date photoDate) throws FileNotFoundException, IOException, ParseException
//    {
//        vtPossibleTag.addAll(generateUserEventTag(photoDate));
//        vtPossibleTag.addAll(generateFriendEventTag(photoDate));
//        return vtPossibleTag;
//
//    }
//    protected ArrayList<PossibleTag> generateUserEventTag(Date photo_date) throws FileNotFoundException, IOException, ParseException
//    {
//
//            FacebookClient fc = new DefaultFacebookClient(FacebookToken.accessToken(TokenFile.getText()));
//            JsonObject user = fc.fetchObject("me/events", JsonObject.class);
//            int ev = user.getJsonArray("data").length();
//
//            PossibleTag event = new PossibleTag();
//            ArrayList<PossibleTag> myEvents = new ArrayList<PossibleTag>();
//
//            for(int i=0; i < ev; i++)
//            {
//                Event userEvents = fc.fetchObject(user.getJsonArray("data").getJsonObject(i).getString("id"), Event.class);
//                Date eventBegin = userEvents.getStartTime();
//                Date eventEnd = userEvents.getEndTime();
//
//                int EventDayBegin = eventBegin.getDate();
//                int EventMonthBegin = eventBegin.getMonth()+1;
//                int EventYearBegin = eventBegin.getYear();
//                int EventHourBegin = eventBegin.getHours();
//                int EventDayEnd = eventEnd.getDate();
//                int EventMonthEnd = eventEnd.getMonth()+1;
//                int EventYearEnd = eventEnd.getYear();
//                int EventHourEnd = eventEnd.getHours();
//                int PhotoDay = photo_date.getDate();
//                int PhotoMonth = photo_date.getMonth()+1;
//                int PhotoYear = photo_date.getYear();
//                int PhotoHour = photo_date.getHours();
//
//                if((PhotoYear >= EventYearBegin) && (PhotoYear <= EventYearEnd))
//                {
//                    if((PhotoMonth >= EventMonthBegin) && (PhotoMonth <= EventMonthEnd))
//                    {
//                        if((PhotoDay >= EventDayBegin) && (PhotoDay <= EventDayEnd))
//                        {
//                            if((PhotoHour >= EventHourBegin) && (PhotoHour <= EventHourEnd))
//                            {
//                                event.setValue(userEvents.getName());
//                                event.setPrecision(0.9);
//                                event.setSufix("Event");
//                            }
//                        }
//                        else
//                        {
//                            event.setValue(userEvents.getName());
//                            event.setPrecision(0.5);
//                            event.setSufix("Event");
//                        }
//                    }
//                }
//                else
//                {
//                    event.setValue(userEvents.getName());
//                    event.setPrecision(0);
//                    event.setSufix("Event");
//                }
//            myEvents.add(event);
//          }
//      return myEvents;
//    }
//    protected ArrayList<PossibleTag> generateFriendEventTag(Date photo_date) throws FileNotFoundException, IOException, ParseException
//    {
//
//            FacebookClient fc = new DefaultFacebookClient(FacebookToken.accessToken(TokenFile.getText()));
//            JsonObject myFriends = fc.fetchObject("me/friends", JsonObject.class);
//            int fr = myFriends.getJsonArray("data").length();
//
//            PossibleTag event = new PossibleTag();
//            ArrayList<PossibleTag> friendEvents = new ArrayList<PossibleTag>();
//
//            for (int i=0; i < fr; i++)
//          {
//              JsonObject friend = fc.fetchObject(myFriends.getJsonArray("data").getJsonObject(i).getString("id") + "/events", JsonObject.class);
//              int frn = friend.getJsonArray("data").length();
//
//              for(int j=0;j<frn;j++)
//              {
//                Event events = fc.fetchObject(friend.getJsonArray("data").getJsonObject(j).getString("id"), Event.class);
//                Date eventBegin = events.getStartTime();
//                Date eventEnd = events.getEndTime();
//
//                int EventDayBegin = eventBegin.getDate();
//                int EventMonthBegin = eventBegin.getMonth()+1;
//                int EventYearBegin = eventBegin.getYear();
//                int EventHourBegin = eventBegin.getHours();
//                int EventDayEnd = eventEnd.getDate();
//                int EventMonthEnd = eventEnd.getMonth()+1;
//                int EventYearEnd = eventEnd.getYear();
//                int EventHourEnd = eventEnd.getHours();
//                int PhotoDay = photo_date.getDate();
//                int PhotoMonth = photo_date.getMonth()+1;
//                int PhotoYear = photo_date.getYear();
//                int PhotoHour = photo_date.getHours();
//
//                if((PhotoYear >= EventYearBegin) && (PhotoYear <= EventYearEnd))
//                {
//                    if((PhotoMonth >= EventMonthBegin) && (PhotoMonth <= EventMonthEnd))
//                    {
//                        if((PhotoDay >= EventDayBegin) && (PhotoDay <= EventDayEnd))
//                        {
//                            if((PhotoHour >= EventHourBegin) && (PhotoHour <= EventHourEnd))
//                            {
//                                event.setValue(events.getName());
//                                event.setPrecision(0.9);
//                                event.setSufix("Event");
//                            }
//                        }
//                        else
//                        {
//                            event.setValue(events.getName());
//                            event.setPrecision(0.5);
//                            event.setSufix("Event");
//                        }
//                    }
//                }
//                else
//                {
//                    event.setValue(events.getName());
//                    event.setPrecision(0);
//                    event.setSufix("Event");
//                }
//            friendEvents.add(event);
//         }
//      }
//    return friendEvents;
//  }
//}
